package com.bao.work.message.impl;

import com.bao.work.message.Message;
import com.bao.work.message.MessageManagement;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author baoye
 * @date 2024-07-31/17:20
 */
public class MessageManagementImpl implements MessageManagement {
    @Override
    public void inputMessage() {
        System.out.println("请输入留言人姓名:");
        String name=INPUT.next();
        String time=new SimpleDateFormat("yyyy年MM月dd日").format(new Date());
        System.out.println("当前日期为:"+time);
        System.out.println("请输入标题");
        String title=INPUT.next();
        System.out.println("请输入留言内容");
        INPUT.nextLine();
        String massageMain=INPUT.nextLine();
        Message message=new Message(name,time,title,massageMain);
        MESSAGE_QUEUE.add(message);
        System.out.println("添加成功");
    }

    @Override
    public void selectMessage() {
        MESSAGE_QUEUE.forEach(System.out::println);
    }
}
